// service/earnestMoney/earnestMoney.js
const app = getApp()
import http from "../../utils/http"
import util from "../../utils/util"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    grade:['#B3704E','#C79F33','#824EB3'],
    list: [],
    info: '',
    safeBottom: `30px`,
  },
  // 充值
  toRecharge(){
    util.skip('/service/recharge/recharge')
  },
  // 账户流水
  toBill(){
    util.skip('/service/bill/bill')
  },
  withdraw(){
    util.skip('/service/withdraw/withdraw?type=4')
  },
  withdrawLog(){
    util.skip('/service/moneyRecord/moneyRecord?type=4')
  },
  getList() {
    http.get('ensure/shopensure').then(res => {
      if (res.data.length === 0) {
        this.setData({
          finish: true
        })
      }
      let arr = this.data.list.concat(res.data)
      this.setData({
        list: arr
      })

    })
  },
  infoTap(e){
    let info = e.currentTarget.dataset.info
    let name = e.currentTarget.dataset.name
    let id = app.globalData.config[info]
    util.skip('/service/info/info?id='+id+'&name='+name)
  },
  getInfo(){
    http.get('shop/shopindex').then(res => {
      this.setData({
        info: res.data
      })
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const high = app.globalData.safeBottom
    this.setData({
      safeBottom: `${high}px`
    })
    this.getList()
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getInfo()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})